window.onload=function () {
        var as=document.getElementsByClassName('content-header')[0].getElementsByTagName('a');
        var contents=document.getElementsByClassName("dom");
        for (var i=0;i<as.length;i++){
            var a=as[i];
            a.id=i;
            // 设置每个a标签的onclick事件
            a.onclick=function () {
                // 清楚所有标签的css设置，隐藏dom标签
                for(var j=0;j<as.length;j++){
                    as[j].className="";
                    contents[j].style.display="none";
                }
                // 设置当前标签样式及当前标签下的所有dom标签可见
                this.className='current';
                // 当前div可见
                contents[this.id].style.display='block';
            }
        }
}

function FocusItem(obj)
{
    obj.parentNode.parentNode.className = "";
    var msgBox = obj.parentNode.getElementsByTagName("span")[0];
    msgBox.innerHTML = "";
    msgBox.className = "";
}

function CheckItem(obj)
{
    obj.parentNode.parentNode.className = "";
    var msgBox = obj.parentNode.getElementsByTagName("span")[0];
    switch(obj.name) {
        case "username":
            if(obj.value == "") {
                msgBox.innerHTML = "昵称不能为空";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }
            break;
        case "usernumber":
            if(obj.value == "") {
                msgBox.innerHTML = "账号不能为空";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }
            break;
        case "password":
            if(obj.value == "") {
                msgBox.innerHTML = "密码不能为空";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }else if(obj.value.length<6||obj.value.length>20){
                msgBox.innerHTML ="密码长度应该为6-20位！";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }
            break;
        case "rePassword":
            if(obj.value == "") {
                msgBox.innerHTML = "确认密码不能为空";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            } else if(obj.value != document.getElementById("password").value) {
                msgBox.innerHTML = "两次输入的密码不相同";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }
            break;
    }
    return true;
}

function checkForm(frm)
{
    //var els = frm.getElementsByTagName("input");
    var els = frm.elements;
    for(var i=0; i<els.length; i++) {
        //if(typeof(els[i].getAttribute("onblur")) == "function") {
        if(!CheckItem(els[i])) return false;
        //}
    }
    return true;
}
